package com.googlecode.nauka.mydbplugin.editor;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.editors.text.FileDocumentProvider;


public class SQLDocumentProvider extends FileDocumentProvider{

    protected IDocument createDocument(Object element) throws CoreException{
        IDocument document = new Document();
        if(element instanceof SQLEditorInput){
            SQLEditorInput input = (SQLEditorInput)element;
            document.set(input.getQuery());
        }
        return document;
    }

    public boolean isModifiable(Object element){
        if(element instanceof SQLEditorInput)
            return true;
        else
            return false;
    }

    public boolean isReadOnly(Object element){
        return !isModifiable(element);
    }
}
